package com.photoeditor.demo.ui.widget.face;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;

import com.photoeditor.R;
import com.photoeditor.demo.util.FontUtil;

public class FontTextView extends android.support.v7.widget.AppCompatTextView {
    private static final int NORMAL_STYLE = 0;
    private static final int BOLD_STYLE = 1;
    private static final int AN_HEAVY_STYLE = 2;
    public static final int AN_MEDIUM_STYLE = 3;
    public static final int AN_BLACK_STYLE = 4;
    private int mFontStyle;

    public FontTextView(Context context) {
        this(context, null);
    }

    public FontTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.FontTextView, 0, 0);
        mFontStyle = typedArray.getInteger(R.styleable.FontTextView_textFont, NORMAL_STYLE);
        typedArray.recycle();

        setFontStyle(mFontStyle);
    }

    public void setFontStyle(int mFontStyle) {
        switch (mFontStyle){
            case NORMAL_STYLE:
                FontUtil.setCustomFontMwRegular(this);
                break;
            case BOLD_STYLE:
                FontUtil.setCustomFontMwBold(this);
                break;
            case AN_HEAVY_STYLE:
                FontUtil.setCustomFontHeavy(this);
                break;
            case AN_MEDIUM_STYLE:
                FontUtil.setCustomFontMedium(this);
                break;
            case AN_BLACK_STYLE:
                FontUtil.setCustomFontBlack(this);
                break;
            default:
        }
    }

}
